/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Table;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import Model.Pasien;
import Model.Rekam;

/**
 *
 * @author BIMO
 */
public class TablePemeriksaan extends AbstractTableModel {

    private List<Rekam> kategoris = new ArrayList<Rekam>();

    public TablePemeriksaan(List<Rekam> kategoris) {
        this.kategoris = kategoris;
    }

    public void deleteKategori(int row) {
        kategoris.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateKategori(int row, Rekam kategori) {
        kategoris.set(row, kategori);
        fireTableRowsUpdated(row, row);
    }

    public void addKategori(Rekam kategori) {
        kategoris.add(kategori);
        fireTableRowsInserted(getRowCount() - 1, getColumnCount() - 1);
    }

    public int getRowCount() {
        return kategoris.size();
    }

    public int getColumnCount() {
        return 3;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Rekam b = kategoris.get(rowIndex);
        switch (columnIndex) {
            case 0:
        Pasien pas = new Pasien();
        pas = b.getNoIndex();
        return pas.getNoIndex();
            case 1:
               
                pas = b.getNoIndex();
                return pas.getNamaPasien();
            case 2:
                return b.getKeluhan();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "No Index";
            case 1:
                return "Nama Pasien";
            case 2:
                return "Keluhan";
            default:
                return "";
        }
    }
}
